<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template Library</title>

<style type='text/css' media='all'>@import url('./userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
<script type="text/javascript" src="js/nav.js"></script>

<meta http-equiv='expires' content='-1' />
<meta http-equiv= 'pragma' content='no-cache' />
<meta name='robots' content='all' />

</head>
<body>

<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('null');</script></div></div>
<div id="nav2"><a name="top">&nbsp;</a><a href="#" id="toggle_toc"><img src="images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>Documentation</h1></td>
<td id="breadcrumb_right">Author:<a href="http://philsturgeon.co.uk">Phil Sturgeon</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->


<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://philsturgeon.co.uk/code/codeigniter-template">Template</a> &nbsp;&#8250;&nbsp;
Documentation
</td>
</tr>
</table>
<!-- END BREADCRUMB -->

<br clear="all" />


<!-- START CONTENT -->
<div id="content">
	<h1>Template</h1>

	<h2>Method Reference</h2>

	<a name="title"></a>
	<h2>title()</h2>
	<p>Set the title of the page.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$title1</var> - string REQUIRED - send as many parameters as you like, they will be imploded with <var>$config['title_separator']</var> to create a single string, which can be called with <kbd>$template['title'];</kdb> in your layouts.</li>
	</ol>

	<p><b>Usage</b></p>
	<pre>$this->template->title('Blog', $article->title);</pre>
	<br />

	<a name="set"></a>
	<h2>set()</h2>
	<p>Set data using a chainable method. Provide two strings or an array of data.</p>

	<p><b>Usage</b></p>
	<pre>$this->template->set('foo', $bar);</pre>

	<p><b>Usage</b></p>
	<pre>$this->template->build('welcome_message', array('message' => 'Hi there!');</pre>
	<br />

	<a name="prepend_metadata"></a>
	<h2>prepend_metadata()</h2>
	<p>Add a line to the start of the <var>$template['metadata']</var> string.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$line</var> - string REQUIRED - Metadata line.</li>
	</ol>

	<p><b>Usage</b></p>
	<pre>
		$this->template->prepend_metadata('&lt;script src="/js/jquery.js">&lt;/script>);
	</pre>
	<br />

	<a name="append_metadata"></a>
	<h2>append_metadata()</h2>
	<p>Add a line to the end of the <var>$template['metadata']</var> string.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$line</var> - string REQUIRED - Metadata line.</li>
	</ol>

	<p><b>Usage</b></p>
	<pre>
		$this->template->append_metadata('&lt;script src="/js/jquery.flot.js">&lt;/script>');
	</pre>
	<br />

	<a name="set_layout"></a>
	<h2>set_layout()</h2>
	<p>All <a href="layouts.html">Layout</a> files should be in the layout folder and by default will be <var>application/views/layouts/default.php</var>, but this can be changed.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$layout</var> - string REQUIRED - name of the theme.</li>
	</ol>

	<p><b>Usage</b></p>
	<pre>
		$this->template<br/>
			->set_layout('two_col') // application/views/layouts/two_col.php
			->build('welcome_message'); // views/welcome_message
	</pre>
	<br />

	<a name="set_theme"></a>
	<h2>set_theme()</h2>
	<p>Will override the theme set in <var>$config['theme']</var>.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$theme</var> - string REQUIRED - name of the theme.</li>
	</ol>

	<a name="set_partial"></a>
	<h2>set_partial()</h2>
	<p>Set <a href="partials.html">Partials</a> from view files.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$name</var> - string REQUIRED - assign a name to the partial.</li>
		<li><var>$view</var> - string REQUIRED - name of the view file to look for.</li>
		<li><var>$data</var> - array/object OPTIONAL - assign some extra data JUST for this partial.</li>
	</ol>

	<p><b>Usage</b></p>

	<pre>$this->template

	// application/views/some_folder/header
	->set_partial('header', 'some_folder/header')

	// application/views/layouts/two_col.php
	->set_layout('two_col')

	// views/welcome_message
	->build('welcome_message');</pre>
	<br />

	<a name="inject_partial"></a>
	<h2>inject_partial()</h2>
	<p>Inject a chunk of HTML as a <a href="partials.html">Partial</a>.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$name</var> - string REQUIRED - assign a name to the partial.</li>
		<li><var>$string</var> - string REQUIRED - Chunk of HTML/Text/Whatever to go into the partial.</li>
		<li><var>$data</var> - array/object OPTIONAL - assign some extra data JUST for this partial.</li>
	</ol>

	<p><b>Usage</b></p>

	<pre>$this->template

	// application/views/some_folder/header
	->inject_partial('header', '&lt;h1>Hello World!&lt;/h1>')

	// application/views/layouts/two_col.php
	->set_layout('two_col')

	// views/welcome_message
	->build('welcome_message');</pre>
	<br />

	<a name="build"></a>
	<h2>build()</h2>
	<p>Build the entire HTML combining partials, layouts and views.</p>

	<p><strong>Parameters</strong></p>
	<ol>
		<li><var>$view</var> - string REQUIRED - Name of the view to use for the template body.</li>
		<li><var>$data</var> - array/object OPTIONAL - Add more data to be mixed with any data already added via <kbd><a href="#set">$this->template->set();</a></kbd>.</li>
	</ol>

	<p><strong>Return</strong></p>
	<ul>
		<li>string. If the 3rd argument is set to <kbd>TRUE</kbd> this method will return the HTML as a string.</li>
	</ul>

</div>
<!-- END CONTENT -->


<div id="footer">
	<p><a href="#top">Top of Page</a></p>
	<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2010 Phil Sturgeon &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
</div>

</body>
</html>